package com.example.qx;

import android.location.Location;

public class speed {
    private Location location;
    private long time;
    public  speed(){
        location=null;
        time=0;
    }
    public double calculatespeed(Location nowloaction){
        if(location==null)
        { location=nowloaction;
        time=System.currentTimeMillis();
        return 0.0;}
        long timec =System.currentTimeMillis() -time;
        double distance= location.distanceTo(nowloaction);
        double speed=(distance/timec)*3600;
        time=System.currentTimeMillis();
        location=nowloaction;
        return speed;

    }
}
